<template>
  <view class="container">
    <!-- 页面背景图 -->
    <image 
      class="page-bg" 
      src="https://mp-1de2ab47-60cc-4717-bb0c-985e43d6d68e.cdn.bspapp.com/img/information_bg.png" 
      mode="aspectFill"
    ></image>
    
    <view class="box-container">
      <!-- 单个盒子 -->
      <view 
        class="box" 
        v-for="(item, index) in boxList" 
        :key="index" 
        @tap="navTo(item.path)"
      >
        <!-- 标题盒子 -->
        <view class="title-box">
          <text class="box-header">{{ item.title }}</text>
        </view>

        <!-- 内容盒子 -->
        <view class="content-box">
          <!-- 动态绑定不同背景图 -->
          <image 
            class="content-bg" 
            :src="item.contentBg" 
            mode="scaleToFill"
          ></image>
          <view class="content-wrapper">
            <text class="box-desc">{{ item.desc }}</text>
          </view>
        </view>
      </view>
    </view>
    <!-- 新增规则盒子 -->
    <view class="rule-box">
      <text class="rule-title">----规则----</text>
      <view class="rule-grid">
        <view 
          class="rule-item" 
          v-for="(rule, idx) in ruleList" 
          :key="idx"
          @tap="navigateToRule(idx)" 
        >
          <image 
            class="rule-bg" 
            :src="rule.bg" 
            mode="aspectFill"
            style="pointer-events: none;"
          ></image>
          <view class="rule-content">
            <text class="rule-num">{{ rule.num }}</text>
            <text class="rule-desc">{{ rule.desc }}</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      boxList: [
        {
          title: '----探索----',
          contentBg: 'https://mp-1de2ab47-60cc-4717-bb0c-985e43d6d68e.cdn.bspapp.com/img/explore/explore.png',
          desc: '答题知掼牛\n发现你所不知道的掼牛',
          path: '/pages/answerBull/answerBull'
        },
        {
          title: '----历史----',
          contentBg: 'https://mp-1de2ab47-60cc-4717-bb0c-985e43d6d68e.cdn.bspapp.com/img/explore/history.png',
          desc: '今日带你了解',
          path: '/pages/history/history'
        },
        {
          title: '----传承人----',
          contentBg: 'https://mp-1de2ab47-60cc-4717-bb0c-985e43d6d68e.cdn.bspapp.com/img/explore/people.png',
          desc: '',
          path: '/pages/inheritor/inheritor'
        }
      ],
      ruleList: [
        {
          num: "01",
          desc: "场地要求",
          bg: "https://mp-1de2ab47-60cc-4717-bb0c-985e43d6d68e.cdn.bspapp.com/img/explore/1.png",
          detail:""
        },
        {
          num: "02",
          desc: "比赛流程",
          bg: "https://mp-1de2ab47-60cc-4717-bb0c-985e43d6d68e.cdn.bspapp.com/img/explore/2.png",
          detail:""
        },
        {
          num: "03",
          desc: "评判标准",
          bg: "https://mp-1de2ab47-60cc-4717-bb0c-985e43d6d68e.cdn.bspapp.com/img/explore/3.png",
          detail:""
        },
        {
          num: "04",
          desc: "动作技巧", 
          bg: "https://mp-1de2ab47-60cc-4717-bb0c-985e43d6d68e.cdn.bspapp.com/img/explore/4.png",
          detail:""
        }
      ]
    }
  },
  methods: {
    navigateToRule(idx) {
      console.log('点击成功')
      try {
        uni.navigateTo({
          url: `/pages/rule/rule?idx=${idx}`,
          fail: (err) => {
            console.error('跳转失败：', err)
            uni.showToast({ title: '页面不存在', icon: 'none' })
          }
        });
      } catch (e) {
        console.error('参数序列化错误：', e)
        uni.showToast({ title: '数据异常', icon: 'none' })
      }
    },
    navTo(path) {
      uni.navigateTo({
        url: path
      })
    }
  }
}
</script>

<style scoped>
/* 页面背景 */
.page-bg {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 0;
  filter: brightness(0.98);
}

.container {
  position: relative;
  z-index: 1;
  padding: 40rpx 30rpx;
  min-height: 100vh;
}

/* 盒子容器 */
.box-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 整体盒子样式 */
.box {
  width: 100%;
  border-radius: 24rpx;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.box:active {
  transform: scale(0.98);
}

/* 标题盒子 */
.title-box {
  padding: 28rpx 40rpx;
  position: relative;
}

.title-box::after {
  content: '';
  position: absolute;
  bottom: -20rpx;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 40rpx;
  border-radius: 50%;
  filter: blur(10rpx);
}

.box-header {
  display: block;
  font-size: 36rpx;
  color: #876946;
  font-weight: 600;
  text-align: center;
  letter-spacing: 2rpx;
  text-shadow: 0 2rpx 4rpx rgba(0,0,0,0.2);
}

/* 内容盒子 */
.content-box {
  position: relative;
  min-height: 400rpx;
  background: #FFFDFA;
}

/* 动态背景图样式 */
.content-bg {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 1;
  mix-blend-mode: multiply; /* 添加混合模式 */
}

.content-wrapper {
  position: relative;
  z-index: 2;
  padding: 40rpx;
  display: flex;
  align-items: center;
  min-height: 260rpx;
}
.box-desc {
  flex: 1;
  font-size: 30rpx;
  color: #FFFFFF;
  line-height: 1.8;
  white-space: pre-wrap;
}
/* 新增规则盒子样式 */
.rule-box {
  width: 90%;
  background: rgba(255,255,255,0.9);
  border-radius: 24rpx;
  padding: 30rpx;
  box-shadow: 0 8rpx 24rpx rgba(0,0,0,0.08);
}

.rule-title {
  display: block;
  font-size: 36rpx;
  color: #876946;
  text-align: center;
  font-weight: 600;
  margin-bottom: 40rpx;
  letter-spacing: 4rpx;
}

.rule-grid {
  display: flex;
  justify-content: space-between;
}

.rule-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 23%;
  height: 400rpx;
  position: relative;
  border-radius: 16rpx;
  overflow: hidden;
}

.rule-bg {
  width: 100%;
  height: 100%;
}

.rule-content {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.rule-num {
  font-size: 44rpx;
  color: #8B4513;
  font-weight: bold;
  text-shadow: 0 2rpx 4rpx rgba(255,255,255,0.5);
  margin-bottom: 15rpx;
}

.rule-desc {
  font-size: 36rpx;
  font-weight: 600;
  color: #5A4A42;
  text-align: center;
  line-height: 1.5;
  white-space: pre-wrap;
}
</style>    